/**
 * Demonstrates a range of Button options the framework offers out of the box
 */
Ext.define('cloud.view.article.ArticleEdit', {
    extend: 'Ext.form.Panel',
    xtype: 'articleEdit',
    editor: false,
    config: {
        title: '广告详情',
        items: [
            {
                xtype: 'toolbar',
                docked: 'bottom',
                layout: {
                    type: 'hbox',
                    pack: 'end'
                },
                items: [
                    {
                        id: 'article_edit',
                        iconMask: true,
                        scope: this,
                        cls:'x-button2',
                        text: '修改提交',
                        style: 'float:right'
                    },
                    {
                        id: 'article_delet',
                        iconMask: true,
                        cls:'x-button2',
                        scope: this,
                        text: '删除',
                        style: 'float:right'
                    }
                ]
            },
            {
                xtype: 'fieldset',
                title: '资讯详情',
                items: [
                    {
                        xtype: 'textfield',
                        label:'资讯ID',
                        name: 'caid',
                        id: 'article_edit_caid',
                        hidden:true
                    },
                    {
                        xtype: 'selectfield',
                        store: 'ArticleCategoryStore',
                        id: 'article_edit_ccid',
                        name: 'ccid',
                        label: '选择分类',
                        displayField: 'name',
                        valueField: 'ccid'
                    },
                    {
                        xtype:'textfield',
                        label:'资讯名',
                        name:'name',
                        id:'article_edit_name'
                    },
                    {
                        xtype:'togglefield',
                        label:'是否开启',
                        name:'status',
                        id:'article_edit_status'
                    },
//                    {
//                        xtype:'textfield',
//                        label:'资讯内容',
//                        name:'content',
//                        id:'article_edit_content'
//                    } ,
                    {
                        xtype: 'textareafield',
                        id: 'article_edit_content',
                        name: 'content',
                        label: '应用描述',
                        required: true
                    },
                    {
                        xtype: 'panel',
                        layout: 'hbox',
                        items: [
                            {
                                xtype: 'label',
                                style:'width:30%;',
                                cls:'x-form-label',
                                html: '<span>封面图片</span>'
                            },
                            {
                                xtype: 'panel',
                                layout: 'vbox',
                                items: [
                                    {
                                        id:'artic_upload',
                                        style:'margin:10px',
                                        html:'<input id="article_img"  type="file" onchange="previewImage(this)"  />'
                                    },
                                    {
                                        id:'artic_showImage',
                                        style: 'margin:10px',
                                        html:'<div id="preview"><img id="imghead" width=150 height=150 src=""></div>'
                                    }
                                ]
                            }
                        ]
                    }

                ]
            }
        ],
        listeners: {
            initialize: function() {

            },
            activate: function() {

            }
        }
    },
    initeditor: function() {
        if(!this.editor){
            var textareas = document.getElementsByName("content")[0];

            var clientWidth = document.body.offsetWidth;
//            textareas.style.width = (clientWidth * 0.68) +"px";
            textareas.style.width ='100%';
            textareas.style.height = "300px";
            // nicEditors.allTextAreas({iconsPath : 'nicEditorIcons.gif'});
            new nicEditor({iconsPath : 'nicEditorIcons.gif'}).panelInstance(textareas);
            this.editor = true;

        }
    }
});
